﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.ServiceModel.Description;
using System.Text;
using System.Threading.Tasks;
using WFExtended.Samples.Model;

namespace WFExtended.Samples.ServiceModel
{
    [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
    public class MyService : IMyService
    {
        private static bool _firstCall = true;

        public void Ping()
        {
            CheckFirstCall();
            Console.WriteLine("Call Ping Operation Method in service MyService");
        }

        public int Test(int param1, int param2)
        {
            CheckFirstCall();
            Console.WriteLine("Call Test Operation Method in service MyService");
            return param1 * param2;
        }

        private void CheckFirstCall()
        {
            if (_firstCall)
            {
                _firstCall = false;
                throw new Exception("First Call Error !");
            }
        
        }
    }
}
